package com.qf.config;




import org.apache.http.HttpHost;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestClientBuilder;
import org.elasticsearch.client.RestHighLevelClient;
import org.springframework.beans.factory.annotation.Value;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/*
 * @Data: 2021/7/22 19:45
 * */
@Configuration
public class EsConfig {
    @Value("${spring.data.elasticsearch.host}")
    private String host;
    @Value("${spring.data.elasticsearch.port}")
    private int port;
    @Bean
    public RestHighLevelClient restHighLevelClient(){

        RestClientBuilder clientBuilder = RestClient.builder(new HttpHost(host, port));
        RestHighLevelClient restHighLevelClient=new RestHighLevelClient(clientBuilder);
        return restHighLevelClient;

    }
}
